<!-- 厂家-维修详情 -->
<template>
	<ListLayout>

		<Tips :leftText="'派单时间:'+SendRepairInfo.createTime" :rightText="stateParams.text" :color="stateParams.color[stateParams.state]"> </Tips>



		<!-- 维修中-报价信息 -->
		<QuoteDetailCard :sendRepairInfo="SendRepairInfo" :showQuoteInfo="ShowQuoteInfo" :quoteInfo="FactoryQuoteInfo"></QuoteDetailCard>
		<!-- 维修中-科室信息 -->
		<DepartmentDetailCard :sendRepairInfo="SendRepairInfo"></DepartmentDetailCard>
		<!-- 维修中-设备信息 -->
		<DeviceCard :sendRepairInfo="SendRepairInfo"></DeviceCard>
		<!-- 维修中-故障信息 -->
		<FaultCard :sendRepairInfo="SendRepairInfo"></FaultCard>



		<template #footer>
			<template v-if="stateParams.state == 7">
				<!-- 维修结算 -->
				<view class=" u-p-l-30   u-p-r-30 u-p-b-18 u-p-t-18">
					<HButton @click="onSettlement">{{StateButtonText[stateParams.state].text}}</HButton>
				</view>
			</template>
			<template v-else>

				<HButtonGroup @leftClick="onLeftClick" @rightClick="onRightClick">
					<template #left>
						无法维修
					</template>
					<template #right>
						{{StateButtonText[stateParams.state].text}}
					</template>
				</HButtonGroup>
			</template>
		</template>
	</ListLayout>

</template>


<script>
	import ListLayout from '@/components/layout/listLayout.vue'
	import QuoteDetailCard from '@/components/card/sendRepair/factory/info/quoteDetail.vue'
	import DepartmentDetailCard from '@/components/card/sendRepair/department/info/departmentDetail.vue'
	import DeviceCard from '@/components/card/sendRepair/factory/info/device.vue'
	import FaultCard from '@/components/card/sendRepair/factory/info/fault.vue'
	import Tips from '@/components/tips/orderTips.vue'
	import HButtonGroup from '@/components/buttonGroup/groupTwo.vue'
	import HButton from '@/components/button/index.vue'
	import ReapirApi from '@/apis/repair.js'
	import { factoryState } from '@/sendRepair/factory/state.js'
	import SendRepairRouterConfig from '@/sendRepair/routerConfig.js'
	export default {

		components: {
			Tips,
			ListLayout,
			QuoteDetailCard,
			DepartmentDetailCard,
			DeviceCard,
			FaultCard,
			HButtonGroup,
			HButton,
		},

		data() {

			return {
				data: {},
				stateParams: {
					color: factoryState.colors,
					text: '',
					state: ''
				},
				routerParams: {
					id: ''
				},

			}
		},

		computed: {
			StateButtonText() {
				return factoryState.buttonParams
			},
			//报价信息内容展示
			ShowQuoteInfo() {
				let {
					QuotationFailed,
					Quotation,
					UnderRepair,
					AbandonRepair
				} = factoryState.stateValue
				console.log([QuotationFailed, Quotation, UnderRepair, AbandonRepair], this.stateParams.state);
				return [QuotationFailed, Quotation, UnderRepair, AbandonRepair].includes(this.stateParams.state)
			},
			// 厂家报价信息
			FactoryQuoteInfo() {
				let {
					manufacturerInfoVo
				} = this.data
				return manufacturerInfoVo || {}
			},
			// 	送修信息
			SendRepairInfo() {
				let {
					repairInfo
				} = this.data
				return repairInfo || {}
			},


		},
		async onLoad(query) {
			const {
				state,
				currStateToName,
				id
			} = query
			this.$set(this.stateParams, 'text', currStateToName)
			this.$set(this.stateParams, 'state', Number(state))
			this.$set(this.routerParams, 'id', id)
			let res = await ReapirApi.common.getDetail(id)
			if (res.code === 0) {
				this.data = res.body || {}
			}
		},
		methods: {
			onSettlement() {
				wx.navigateTo({
					url: `${SendRepairRouterConfig.Factory.Settlement}?id=${this.routerParams.id}`
				})
			},
			//完成维修
			onRightClick() {
				const {
					id
				} = this.routerParams
				const {
					state
				} = this.stateParams
				wx.navigateTo({
					url: `${SendRepairRouterConfig.Factory.RepairComplete}?id=${id}&state=${state}`
				})
			},
			//无法维修
			onLeftClick() {
				let self = this
				wx.navigateTo({
					url: `${SendRepairRouterConfig.Factory.UnableToRepair}?id=${this.routerParams.id}`
				})
				// wx.showModal({
				// 	title: '提示',
				// 	content: '确认无法维修?',
				// 	success(res) {
				// 		if (res.confirm) {
				// 			ReapirApi.factory.confirmDeviceRepair({
				// 				id: self.routerParams.id
				// 			}).then(() => {
				// 				wx.showToast({
				// 					title: "提交成功",
				// 					icon: 'success',
				// 					complete() {
				// 						wx.navigateTo({
				// 							url: `/pages/sendRepair/factory/pages/index`
				// 						})
				// 					}
				// 				})
				// 			})
				// 		}
				// 	}
				// })


			}
		},

	}
</script>
<style lang="scss" scoped>
	.tips {
		display: flex;
		margin-top: 20rpx;

		>.time {
			font-weight: 600;
			font-size: 28rpx;
			color: #98A5B3;
			flex: 4;
		}

		>.state {
			font-weight: 600;
			font-size: 28rpx;
			color: #F56C6C;
			flex: 1;
			text-align: right;
		}
	}
</style>
